﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KPIS.GERP.GFMS.MODEL;
using KPIS.GERP.GFMS.IBLL;
using KPIS.GERP.GFMS.IDAL;
using KPIS.GERP.GFMS.DALFactory;

// test only
using KPIS.GERP.GFMS.DAL;

namespace KPIS.GERP.GFMS.BLL
{
    [Serializable]
    public class B_FIM_MoneyRequestDtls : IBLL_FIM_MoneyRequestDtls
    {
        Common common = new Common();
        private static readonly IDAL_FIM_MoneyRequestDtls dal = DataAccess.Create_FIM_MoneyRequestDtls();

        public B_FIM_MoneyRequestDtls()
        {

        }

        public IList<M_FIM_MoneyRequestDtls> GetFull(string money_req_seq)
        {
            Nullable<int> nmoney_req_seq = common.ConvertNullInt(money_req_seq);
            return dal.GetFull(nmoney_req_seq);
        }

        public IList<M_FIM_MoneyRequestDtls> GetExpFromProject(string bgm_project_seq
            , string bgm_source_seq, string bgm_exp_grp_seq, string money_req_seq)
        {
            Nullable<int> nbgm_project_seq = common.ConvertNullInt(bgm_project_seq);
            Nullable<int> nbgm_source_seq = common.ConvertNullInt(bgm_source_seq);
            Nullable<int> nbgm_exp_grp_seq = common.ConvertNullInt(bgm_exp_grp_seq);
            Nullable<int> nmoney_req_seq = common.ConvertNullInt(money_req_seq);
            return dal.GetExpFromProject(nbgm_project_seq, nbgm_source_seq, nbgm_exp_grp_seq, nmoney_req_seq);
        }

        public double GetExpInApproveProcess(string bgm_proj_oper_seq
            , string bgm_source_seq, string bgm_exp_grp_seq, string money_req_seq)
        {
            Nullable<int> nbgm_project_seq = common.ConvertNullInt(bgm_proj_oper_seq);
            Nullable<int> nbgm_source_seq = common.ConvertNullInt(bgm_source_seq);
            Nullable<int> nbgm_exp_grp_seq = common.ConvertNullInt(bgm_exp_grp_seq);
            Nullable<int> nmoney_req_seq = common.ConvertNullInt(money_req_seq);
            return dal.GetExpInApproveProcess(nbgm_project_seq, nbgm_source_seq, nbgm_exp_grp_seq, nmoney_req_seq);
        }

        public IList<M_BGM_MAS_Expense> GetExpList(string money_req_seq)
        {
            Nullable<int> nmoney_req_seq = common.ConvertNullInt(money_req_seq);
            return dal.GetExpList(nmoney_req_seq);
        }

        public IList<M_FIM_MoneyRequestDtls> GetList(string money_req_seq)
        {
            Nullable<int> nmoney_req_seq = common.ConvertNullInt(money_req_seq);
            return dal.GetList(nmoney_req_seq);
        }

        public M_FIM_MoneyRequestDtls GetInfo(string seq)
        {
            int nSeq;
 
            if (seq == null)
                return null;

            if (common.IsNumeric(seq))
            {
                nSeq = int.Parse(seq);
                return dal.GetInfo(nSeq);
            }
            else
            {
                return null;
            }
        }

        //public string SelectRecentInsertedRoleSeq()
        //{
        //    return dal.SelectRecentInsertedRoleSeq();
        //}

        public string Insert(M_FIM_MoneyRequestDtls info)
        {
            try
            {
                return dal.Insert(info);
            }
            catch
            {
                throw;
            }
        }

        public void Update(M_FIM_MoneyRequestDtls info)
        {
            try
            {
                dal.Update(info);
            }
            catch
            {
                throw;
            }
        }

        public void Delete(M_FIM_MoneyRequestDtls info)
        {
            try
            {
                dal.Delete(info);
            }
            catch
            {
                throw;
            }
        }
    }
}
